<template name="privacy-dialog">
	<view class="privacy-dialog">
		<uni-popup :is-mask-click="maskFlag" :mask-click="maskFlag" ref="privacyPop" type="bottom" background-color="#fff">
			<view class="popup-content">
				<view class="title">用户隐私保护提示</view>
				<view class="tips">感谢您使用新东方雅思搜题小程序，您使用本小程序前应当阅读并同意</view>
				<view class="privacyTitle" style="color: royalblue;" @click="openPrivacyContract">{{urlTitle}}</view>
				<view class="tips">当您点击同意并开始使用产品服务时，即表示您已理解并同意该条款内容，该条款将对您产生法律约束力。如您拒绝，将无法使用全部功能。</view>
				<view class="agreeOpera">
					<button id="disagree-btn" class="operaBtn disagree-btn"   @click="handleDisagree">不同意</button>
					<!-- <view class="operaBtn disagree-btn" id="disagree-btn" @click="handleDisagree">不同意</view> -->
					<!-- <view class="operaBtn agree-btn" id="agree-btn" @click="handleAgree">同意并继续</view> -->
					<button id="agree-btn"  class="operaBtn agree-btn" open-type="agreePrivacyAuthorization"  @click="handleAgree">同意并继续</button>
				</view>
			</view>
			
		</uni-popup>
		
	</view>
</template>

<script>
	// import uniPopup from '@/components/uni-popup//uni-popup.vue'
	export default {
		// components:{
		// 	uniPopup
		// },
		name:"privacy-dialog",
		props:{
			title: {
				type: String,
				default: "温馨提示"
			},
			urlTitle: {
				type: String,
				default: ""
			},
			innerShow: {
				type: Boolean,
				default: false
			},
			maskFlag: {
				type: Boolean,
				default: true
			},
			source: {
				type: String,
				default: ""
			},
		},
		data(){
			return{
				testExamTime:""	
			}
		},
		onShow(){
			console.log('=====',this.innerShow)
			
		},
		created(){
			
		},
		mounted(){
			
		},
		methods: {
			handleAgree(e) {
			  this.close() 
			  this.$emit('privacyDio',true)
			  // 这里演示了同时调用多个wx隐私接口时要如何处理：让隐私弹窗保持单例，点击一次同意按钮即可让所有pending中的wx隐私接口继续执行 （看page/index/index中的 wx.getClipboardData 和 wx.startCompass）
			 //  privacyResolves.forEach(resolve => {
				// resolve({
				//   event: 'agree',
				//   buttonId: 'agree-btn'
				// })
			 //  })
			 //  privacyResolves.clear()
			  // this.resolvePrivacyAuthorization({ buttonId: 'agree-btn', event: 'agree' })
			},
			handleDisagree(e) {
			  this.close()
			  console.log('不同意返回首页',this.source)
			  if(this.source=='index'){
				  uni.switchTab({
				  	url:"pages/index/index"
				  })
			  }
			 //  privacyResolves.forEach(resolve => {
				// resolve({
				//   event: 'disagree',
				// })
			 //  })
			 //  privacyResolves.clear()
			 //  this.resolvePrivacyAuthorization({ buttonId: 'disagree-btn', event: 'disagree' })
			},
			open() {
			  this.$refs.privacyPop.open()
			},
			close() {
			  this.$refs.privacyPop.close()
			},
			openPrivacyContract() {
			      wx.openPrivacyContract({
			        success: res => {
			          console.log('openPrivacyContract success')
			        },
			        fail: res => {
			          console.error('openPrivacyContract fail', res)
			        }
			      })
			    }
			
		}
	}
</script>

<style lang="scss" scoped>
	.privacy-dialog {
		font-size: 28rpx;
		.popup-content{
			padding: 30rpx 30rpx 100rpx;
			// height: 200rpx;
			.title{
				margin-bottom: 30rpx;
				font-size: 30rpx;
			}
			.privacyTitle{
				margin: 20rpx 0;
			}
			.tips{
				color: #ccc;
			}
			.agreeOpera{
				margin-top:50rpx;
				display: flex;
				justify-content: space-around;
				.operaBtn{
					// padding:10rpx 0;
					text-align: center;
					font-size: 30rpx;
					width: 214rpx;
					// border: 1px solid #ccc;
					border-radius: 8rpx;
				}
				.agree-btn{
					background-color: #FD453D;
					color:#fff
				}
				.disagree-btn{
					background-color:#F5F5F5 ;
					color: #333333;
				}
				
			}
		}
		
	}

</style>
